import Obj3D from "./Poly/Obj3D";

function getChildren(obj3D: Obj3D): Obj3D[] {
    let arr: Obj3D[] = [];
    const child = obj3D.children;
    if (child.length > 0) {
        for (let obj of child) {
            for (let i of getChildren(obj)) {
                arr.push(i);
            }
        }
    }
    for (let i of child) {
        arr.unshift(i);//头插
    }
    return arr;
}

function getParentIsRoot(obj: any) {
    if (obj == null) {
        return false;
    }
    if (obj.getType() == 'Scene') {
        return true;
    }
    getParentIsRoot(obj.parent);
}

export { getChildren, getParentIsRoot }